﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class RelationMap : EntityTypeConfiguration<Relation>
    {
        public RelationMap()
        {
            ToTable("Relations");
            HasKey(relation => relation.Id);

            Property(relation => relation.RelationNumber).IsRequired();
            Property(relation => relation.Route).IsRequired().HasMaxLength(150);
            Property(relation => relation.ValidFrom).IsRequired();
            Property(relation => relation.ValidTo).IsRequired();
            Property(relation => relation.BorderStation).IsRequired().HasMaxLength(12);
            Property(relation => relation.DestinationStation).IsRequired().HasMaxLength(12);

            HasMany(relation => relation.RelationRus).WithRequired(relationRu => relationRu.Relation);
            HasMany(relation => relation.Descriptions).WithRequired(relationDescription => relationDescription.Relation);
        }
    }
}